Skip to content

fix: handle arrayJoin of empty arrays in clickhouse queries#2682

Merged
JivusAyrus merged 1 commit intomainfrom
suvij/eng-9285-fix-clickhouse-arrayjoin-error-when-fields-array-is-empty
Mar 24, 2026
Merged

fix: handle arrayJoin of empty arrays in clickhouse queries#2682
JivusAyrus merged 1 commit intomainfrom
suvij/eng-9285-fix-clickhouse-arrayjoin-error-when-fields-array-is-empty

Conversation

@JivusAyrus
Copy link
Copy Markdown
Member

@JivusAyrus JivusAyrus commented Mar 24, 2026

Summary by CodeRabbit

  • Performance Improvements
    • Optimized analytics queries to skip unnecessary database operations when querying field usage with empty input sets, resulting in faster response times.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 93d8879f-6e32-47fa-98f0-d84c3c813acb

📥 Commits

Reviewing files that changed from the base of the PR and between 7cc0fdd and 6d5995b.

📒 Files selected for processing (1)
  • controlplane/src/core/repositories/analytics/UsageRepository.ts

Walkthrough

Added early-return guards to two methods in UsageRepository that immediately resolve to an empty array when the input fields array is empty, preventing unnecessary ClickHouse queries with empty arrayJoin SQL operations.

Changes

Cohort / File(s) Summary
Empty array guard clauses
controlplane/src/core/repositories/analytics/UsageRepository.ts
Added early-return guards to getUnusedFields and getUsedFields methods to resolve immediately with empty array when fields parameter is empty, avoiding unnecessary ClickHouse queries.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • fix: usage of input fields on the ui #2437: Modifies the same getUnusedFields and getUsedFields methods in UsageRepository.ts, adding IsNull=false filters to those queries, which may interact with the early-return guard logic introduced in this PR.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding early-return guards to handle empty arrays in ClickHouse arrayJoin queries, which matches the file-level changes and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.27%. Comparing base (1ca1fd0) to head (6d5995b).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...src/core/repositories/analytics/UsageRepository.ts 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2682      +/-   ##
==========================================
- Coverage   64.27%   64.27%   -0.01%     
==========================================
  Files         305      305              
  Lines       43266    43272       +6     
  Branches     4628     4630       +2     
==========================================
  Hits        27811    27811              
- Misses      15433    15439       +6     
  Partials       22       22              
Files with missing lines Coverage Δ
...src/core/repositories/analytics/UsageRepository.ts 51.05% <33.33%> (-0.47%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JivusAyrus JivusAyrus merged commit 733c14b into main Mar 24, 2026
13 checks passed
@JivusAyrus JivusAyrus deleted the suvij/eng-9285-fix-clickhouse-arrayjoin-error-when-fields-array-is-empty branch March 24, 2026 11:29
@JivusAyrus JivusAyrus restored the suvij/eng-9285-fix-clickhouse-arrayjoin-error-when-fields-array-is-empty branch March 24, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants